package com.mea.client;

import org.kalmeo.kuix.core.Kuix;
import org.kalmeo.kuix.core.KuixConstants;
import org.kalmeo.kuix.widget.Screen;
import org.kalmeo.util.frame.Frame;

public class HelloWorldFrame implements Frame {

	public void onAdded() {
		
		// Load the content from the XML file with Kuix.loadScreen static method
	    Screen screen = Kuix.loadScreen("helloworld.xml", null);

	    // Set the application current screen  
	    screen.setCurrent();
	}

	public boolean onMessage(Object identifier, Object[] arguments) {
		if ("searchServer".equals(identifier)) {
	        // display a popup message
			Kuix.getFrameHandler().pushFrame(new SearchServerFrame());
	        return false;
	    }
		if ("about".equals(identifier)) {
	        // display a popup message
	        Kuix.alert("This Helloworld is powered by Kuix", KuixConstants.ALERT_OK);
	        return false;
	    }
	    if ("exitConfirm".equals(identifier)) {
	        // display a popup message
	        Kuix.alert("Are you sure you want to exit?", KuixConstants.ALERT_YES | KuixConstants.ALERT_NO, "exit", null);
	        return false;
	    }
	    if ("exit".equals(identifier)) {
	        // get the midlet instance to invoke the Destroy() method
	        HelloWorld.getDefault().destroyImpl();
	        //if the event has been processed, we return 'false' to avoid event forwarding to other frames
	        return false;
	    }

	    // return "true" makes the FramHandler to forward the message to the next frame in the stack 
	    return true;
	}

	public void onRemoved() {
		// TODO Auto-generated method stub
		
	}

	
}
